﻿using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Media;

namespace FileMatcher
{
    public class FileInfoEx : INotifyPropertyChanged
    {
        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Properties

        public string Name
        {
            get { return _fileInfo.Name; }
        }

        public string DirectoryName
        {
            get { return _fileInfo.DirectoryName; }
        }

        public long Length
        {
            get { return _fileInfo.Length; }
        }

        public string FullName
        {
            get { return _fileInfo.FullName; }
        }

        public bool IsSelectedToDelete
        {
            get { return _isSelectedToDelete; }
            set 
            {
                if (_isSelectedToDelete == value)
                {
                    return;
                }
                _isSelectedToDelete = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("IsSelectedToDelete"));
                    PropertyChanged(this, new PropertyChangedEventArgs("State"));
                }
            }
        }

        public int GroupId
        {
            get { return _groupId; }
            set 
            { 
                if (_groupId == value)
                {
                    return;
                }
                _groupId = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("GropuId"));
                }
            }
        }

        public string State
        {
            get { return IsSelectedToDelete ? "To Delete" : "To Keep"; }
        }

        public FileInfo InternalFileInfo
        {
            get { return _fileInfo; }
        }

        #endregion

        #region Constructors

        public FileInfoEx(FileInfo fileInfo)
        {
            _fileInfo = fileInfo;
        }
        
        #endregion

        #region Fields

        private readonly FileInfo _fileInfo;
        private bool _isSelectedToDelete;
        private int _groupId;

        #endregion
    }
}
